<template>
	<view class="container">
		<uni-card
			class="card"
			style="margin-bottom: 20rpx"
			v-for="item in enterpriseList"
			@click="goToDetail(item.enterpriseId)"
			:key="item.id"
			:title="item.name"
			isFull
			extra="额外信息"
		>
			<view class="msg">
				<view class="item">法定代表人：{{ item.legalRepresentative }}</view>
				|
				<view class="item">工商注册号：{{ item.registrationNo }}</view>
			</view>
			<view class="msg">
				<view class="item">注册资本：{{ item.registeredCapital }}</view>
			</view>
			<view class="msg">
				<view class="item">注册地址：{{ item.registeredAddress }}</view>
			</view>
		</uni-card>
	</view>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { getFavorites } from '../../api/enterprise.js';
import { onShow, onLoad } from '@dcloudio/uni-app';

const enterpriseList = ref([]);
const userId = ref(0);

onLoad((options) => {
	userId.value = options.id;
});

const getFavoriteList = async () => {
	const res = await getFavorites({ id: userId.value });
	enterpriseList.value = res.data;
};

const goToDetail = (id) => {
	console.log(id);
	uni.navigateTo({
		url: `/pages/enterpriseDetail/enterpriseDetail?id=${id}`
	});
};
onLoad(() => {
	getFavoriteList();
});
</script>

<style lang="scss" scoped>
.card {
	position: relative;
	.tag-view {
		position: absolute;
		right: 20rpx;
	}
	.msg {
		display: flex;
		flex-wrap: wrap;
		.item {
			margin: 0 10rpx;
		}
	}
}
</style>
